<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>num</title>
		<script type="text/javascript">
			
			function suan(){
				
				var num1=isNaN(parseInt($2("num1").value)) ? 0:parseInt($2("num1").value);
				var num2=isNaN(parseInt($2("num2").value)) ? 0:parseInt($2("num2").value);
				
				$2("result").value=num1-num2;
			}
			
			function $2(id){
				return document.getElementById(id);
			}
		</script>
	</head>
	<body>
		<div>
			数字1：<input name="num1" id="num1" value="20" />	
			数字2：<input name="num2" id="num2" />	
			结果：<input name="result" id="result" onclick="suan();"/>	
		
		</div>
	</body>
</html>
